﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TeBigCoreApi.Models
{
    public class CommonResponse
    {
        public bool IsSuccess { get; set; } = true;
        public string Message { get; set; }
    }

    public class CommonRequest
    {
        public string Token { get; set; }
    }

    public class DateTimeRequest : CommonRequest
    {
        public DateTime Begin { get; set; }
        public DateTime End { get; set; }
    }

    public class ListResponse<T> : CommonResponse
    {
        public List<T> List { get; set; } = new List<T>();
    } 
}

namespace TeBigCoreApi.Models
{
    public static class ReqRespExtensions
    {
        public static void OnException(this CommonResponse resp, Exception ex)
        {
            resp.IsSuccess = false;
            resp.Message = ex.Message;
        }

        public static void OnFail(this CommonResponse resp, string message)
        {
            resp.IsSuccess = false;
            resp.Message = message;
        }

        public static void OnSuccess(this CommonResponse resp, string message = "")
        {
            resp.IsSuccess = true;
            resp.Message = message;
        }
    }
}